package apiday08.homework;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Class cls =  Class.forName("apiday08.reflect.Person");
        Method method = cls.getMethod("say", String.class, int.class);
        String name = method.getName();
        System.out.println("名字："+name);
        Class type = method.getReturnType();
        System.out.println("返回类型："+type);
        int num = method.getParameterCount();
        System.out.println("参数个数："+num);
        Class[] pcs = method.getParameterTypes();
        System.out.println("参数个数："+pcs.length);
        for (Class p : pcs){
            System.out.println("参数类型："+p);
        }
        int modifiers= method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("访问权限为：public");
                break;
            case Modifier.PRIVATE:
                System.out.println("访问权限为：private");
                break;
            case Modifier.PROTECTED:
                System.out.println("访问权限为：protected");
                break;
            default:
                System.out.println("访问权限为：default");

        }

    }
}
